﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Bootstrapper.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="Bootstrapper" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Windows.Client
{
    using System.Windows;

    using Hisaab.Windows.Client.Adapters;

    using Microsoft.Practices.Prism.Modularity;
    using Microsoft.Practices.Prism.UnityExtensions;
    using Microsoft.Practices.ServiceLocation;
    using Microsoft.Windows.Controls.Ribbon;

    /// <summary>
    /// Defines the <seealso cref="Bootstrapper"/> type.
    /// </summary>
    public class Bootstrapper : UnityBootstrapper
    {
        /// <summary>
        /// Creates the shell.
        /// </summary>
        /// <returns>Shell object</returns>
        protected override DependencyObject CreateShell()
        {
            return new Shell();
        }

        /// <summary>
        /// Initializes the shell.
        /// </summary>
        protected override void InitializeShell()
        {
            base.InitializeShell();

            App.Current.MainWindow = (Window)this.Shell;
            App.Current.MainWindow.Show();
        }

        /// <summary>
        /// Configures the module catalog.
        /// </summary>
        protected override void ConfigureModuleCatalog()
        {
            this.ModuleCatalog = new DirectoryModuleCatalog { ModulePath = @".\Modules" };
        }

        /// <summary>
        /// Configures the region adapter mappings.
        /// </summary>
        /// <returns>Region mapping object</returns>
        protected override Microsoft.Practices.Prism.Regions.RegionAdapterMappings ConfigureRegionAdapterMappings()
        {
            var mappings = base.ConfigureRegionAdapterMappings();
            if (mappings == null)
            {
                return null;
            }

            mappings.RegisterMapping(typeof(Ribbon), ServiceLocator.Current.GetInstance<RibbonRegionAdapter>());

            return mappings;
        }
    }
}